//
//  WebViewController.m
//  MyMovie
//
//  Created by lanou on 15/9/23.
//  Copyright (c) 2015年 HeQiangQiang. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController ()<UIWebViewDelegate>
@property (nonatomic,retain) UIWebView *webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //主要用到UIWebView控件
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height -50 )];
    //  设置代理
    self.webView.delegate = self;
    [self.view addSubview:self.webView];
    
    NSString *urlStr = [NSString stringWithFormat:@"http://piaofang.maoyan.com/" ];
    //  请求网址
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
    //加载网页
    [self.webView loadRequest:request];
    
   
}
//实现协议的方法

//开始加载时触发
- (void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"开始加载");
}
//加载完成触发
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"完成加载");
}
//加载失败
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"加载失败");
    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"提示"
                           
                                                    message:@"加载失败"
                           
                                                   delegate:self
                           
                                          cancelButtonTitle:@"取消"
                           
                                          otherButtonTitles:@"确认",nil];
    [alert show];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
